<template>
  <section>
    一键复制
    <input ref="con">
    </input>
    <button @click="copy">复制</button>
  </section>
</template>

<script>
// import clipboard from 'clipboard'
// console.log(clipboard)

export default {
  name: 'keyCopyDemo',
  data() {
    return {
      dom: null,
    }
  },
  mounted() {
    this.dom = this.$refs.con
    this.dom.value = '默认复制的内容'
  },
  methods: {
    copy() {
      this.dom.select()
      document.execCommand('copy')
      alert(`复制成功:${this.dom.value}`)
    },
  },
}
</script>

<style></style>
